<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul>
        <li>我是li1</li>
        <li>我是li2</li>
        <li>我是li3</li>
        <li>我是li4</li>
        <li>我是li5</li>
    </ul>
    <script>
        let ul=document.querySelector('ul');
        let lis=document.querySelectorAll('li');
        ul.addEventListener('click',function(e){   //把事件委托给ul
            for(let i=0;i<lis.length;i++){
                lis[i].style.backgroundColor="";
                lis[i].style.cursor='pointer';
            }
            e.target.style.backgroundColor='pink'; 
        })
    </script>
</body>
</html>